﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Printing;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using TMI85303.UI.UserControls;
using TMI85303.Utils;

namespace TMI85303.UI.View
{
    /// <summary>
    /// TestWin.xaml 的交互逻辑
    /// </summary>
    public partial class TestWin : Window
    {
        public TestWin()
        {
            InitializeComponent();

            // 获取DataContext并转换为DrawingViewModel
            var viewModel = DataContext as TestWinVM;
            if (viewModel != null)
            {
                // 将CustomCanvas实例赋值给ViewModel的DrawableSurface
                viewModel.DrawableSurface = MyPaint;
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            
        }
    }

    public partial class TestWinVM : ObservableObject
    {
        public IDrawable? DrawableSurface { get; set; }

        [RelayCommand]
        private void DrawSomething()
        {
            //DrawableSurface?.DrawLine(10, 10, 100, 100);
            //DrawableSurface?.DrawRectangle(120, 10, 100, 100);
            //DrawableSurface?.DrawTriangle(10, 100, 100, 100, 55, 10);
            //DrawableSurface?.DrawPoint(20, 20,10);
            DrawableSurface?.DrawCircle(20, 20,10,2, ColorsHelper.Red);
        }

        [RelayCommand]
        private void SetValss()
        {
            //OverallData.Instance.Test1 = Instr ?? "xx";
        }

        [ObservableProperty]
        private string? instr;
    }
}
